local shensu = fk.CreateSkill {
  name = "mini__shensu",
}

Fk:loadTranslationTable{
  ["mini__shensu"] = "神速",
  [":mini__shensu"] = "你可以：跳过判定阶段和摸牌阶段；<br>跳过出牌阶段；<br>你每选择一项，视为使用一张无距离限制且无视防具的【杀】。",

  ["#mini__shensu1-choose"] = "神速：跳过判定阶段和摸牌阶段，视为使用无距离限制、无视防具的【杀】",
  ["#mini__shensu2-choose"] = "神速：跳过出牌阶段，视为使用无距离限制、无视防具的【杀】",
}

shensu:addEffect(fk.EventPhaseChanging, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(shensu.name) and
      not player:prohibitUse(Fk:cloneCard("slash")) and not data.skipped and
      ((data.phase == Player.Judge and player:canSkip(Player.Draw)) or data.phase == Player.Play)
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local use = room:askToUseVirtualCard(player, {
      name = "slash",
      prompt = data.phase == Player.Judge and "#mini__shensu1-choose" or "#mini__shensu2-choose",
      skill_name = shensu.name,
      extra_data = {
        bypass_distances = true,
        bypass_times = true,
        extraUse = true,
      },
      skip = true,
    })
    if use then
      event:setCostData(self, {extra_data = use})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    data.skipped = true
    if data.phase == Player.Judge then
      player:skip(Player.Draw)
    end
    room:useCard(event:getCostData(self).extra_data)
  end,
})

shensu:addEffect(fk.TargetSpecified, {
  can_refresh = function(self, event, target, player, data)
    return table.contains(data.card.skillNames, shensu.name) and data.to:isAlive()
  end,
  on_refresh = function(self, event, target, player, data)
    data.to:addQinggangTag(data)
  end,
})

return shensu
